/*CopyRight 2015 By YXKJ Co., Ltd. All Rights Reserved.*/
package com.yx.system;

import java.io.Serializable;

/**
 * 所有实体对象的基类
 * 
 * @author zgq
 */
public abstract class BaseModel implements Serializable {

	/** 序列化版本号 */
	private static final long serialVersionUID = 1L;

	/**
	 * 以字符串形式返回实体对象对应的数据库表的主键，复合主键以"|"分隔
	 * 
	 * @return 主键字符串
	 */
	public abstract String getPrimaryKey();

	@Override
	public int hashCode() {
		return (this.getPrimaryKey() != null ? this.getPrimaryKey().hashCode()
				: 0);
	}

	@Override
	public boolean equals(Object object) {
		if (this == object)
			return true;
		if (!(object instanceof BaseModel))
			return false;
		BaseModel bm = (BaseModel) object;
		return !(this.getPrimaryKey() != null ? !this.getPrimaryKey().equals(
				bm.getPrimaryKey()) : bm.getPrimaryKey() != null);
	}

	@Override
	public String toString() {
		return this.getPrimaryKey();
	}
}